import { post } from '@/utils/http'
import { packagedSetUrlQuery } from '@/utils/upload-tool'

// 认证记录表头统计
export const recordCountAPI = (data) => post({ url: '/V5/svmsContract/tenantConsumerAmount', data })
// 认证记录
export const recordAPI = (data) => post({ url: '/V5/ident/record', data })
// 下载合同
export const downloadContractFileAPI = (data) => {
  return new Promise((resolve, reject) => {
    post({
      url: '/V5/svmsContract/downloadContractFile',
      data,
    })
      .then((res) => {
        if (res.result) res.result = packagedSetUrlQuery(res.result)
        resolve(res)
      })
      .catch((err) => {
        reject(err)
      })
  })
}
// 发起合同
export const initiateAPI = (data) => post({ url: '/V5/svmsContract/initiate', data })
// 撤回合同
export const revokeAPI = (data) => post({ url: '/V5/svmsContract/revoke', data })
// 作废合同
export const nullifyAPI = (data) => post({ url: '/V5/svmsContract/nullify', data })
// 无需签署
export const invalidAPI = (data) => post({ url: '/V5/svmsContract/invalid', data })
// 获取商户签署链接
export const getTenantSignUrlAPI = (data) => post({ url: '/V5/svmsContract/getTenantSignUrl', data })
// 获取承租方签署链接
export const getLesseeSignUrlAPI = (data) => post({ url: '/V5/svmsContract/getLesseeSignUrl', data })
// 判断余额
export const determineAPI = (data) => post({ url: '/V5/enterprise/determine', data })
// 短租合同列表
export const dzcontractAPI = (data) => post({ url: '/V5/svmsContract/contractRecord', data })
// 长租合同列表
export const czcontractAPI = (data) => post({ url: '/V5/czsOrderInfo/signRecord', data })
// 销毁
export const deleteContractFileAPI = (data) => post({ url: '/V5/svmsContract/deleteContractFile', data })
// 创建合同文件（重新生成）
export const createQysContractAPI = (data) => post({ url: '/V5/svmsContract/createQysContract', data })

// 合同记录获取短租合同数量
export const getContractNumAPI = (data) => post({ url: '/V5/svmsContract/getContractNum', data })

// 合同记录获取长租合同数量
export const getLongContractNumAPI = (data) => post({ url: '/V5/czsOrderInfo/getContractNum', data })

// 获取合同信息
export const getContractDataAPI = (data) => post({ url: '/V5/svmsContract/getContractData', data })

// 查询已发送签署短信数量
export const getMsgNumCountAPI = (data) => post({ url: '/V5/svmsContract/getMsgNumCount', data })

// 修改免费版电子合同
export const updateFreeContractAPI = (data) => post({ url: '/V5/svmsContract/updateFreeContract', data })

// 计算长租租期
export const computeLongRentDayAPI = (data) => post({ url: '/V5/czsOrderInfo/getMonthDiff', data })
// 发送签署短信
export const sendLesseeSignMsgAPI = (data) => post({ url: '/V5/svmsContract/sendLesseeSignMsg', data })
